package com.test.classload;

import java.net.URL;
import java.net.URLClassLoader;

/**
 * Created by lxy on 2018/6/21.
 */
public class LoadServiceDemo {

    public static void main(String[] args) throws Exception{
        URL url = new URL("file:D:\\test");

        URLClassLoader urlClassLoader = new URLClassLoader(new URL[]{url});
        Class<?> aClass = urlClassLoader.loadClass("com.test.classload.LoadService");
        Object o = aClass.newInstance();
        aClass.getMethod("service").invoke(o);

        urlClassLoader.close();


    }

}
